home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
mc51bugs.zip
/
Q31751
< prev
next >
Wrap
Text File
|
1988-07-21
|
1KB
|
61 lines
Q31751 Incorrect Code with /Oal and Do-While Loop
C Compiler
5.10
MS-DOS
Summary:
The code generated for the do-while loop in the example below
is incorrect when it is compiled with /Oal (or /Ox). The generated
code will execute the loop 65535 times, causing memory to be
overwritten and potentially hanging the machine. The do-while loop
should execute only once.
Microsoft has confirmed this to be a problem in Version 5.10 of the
C compiler.
To work around the problem, make an assignment to a dummy variable
inside the do-while loop. For example, changing the following
statement:
++argm;
to the following will work around the problem:
temp = ++argm;
Microsoft is researching this problem and will post new information
as it becomes available.
More Information:
The following code demonstrates the problem:
char *argj[100];
void main()
{
int argn;
int argm;
int argi;
argi = foo(); /* initialize argi to 2 */
argn = 1;
while (argn < argi)
{
argm = argn;
argi--;
do
{
argj[argm] = argj[argm+1];
++argm;
}
while (argm < argi);
argn++;
}
}
foo()
{ return 2;
}
Keywords: buglist5.10 TAR78086
Updated 88/07/21 03:19